#ifndef FORMGETRECEIPT_H
#define FORMGETRECEIPT_H

#include <QWidget>
#include <housingdbms.h>
#include "dlgsettings.h"
#include <QList>
#include <QPair>
#include "dbmscontainer.h"
#include "modelcontainer.h"
#include "billsmodel.h"

#ifdef Q_OS_WIN
#include <sleeexcel.h>
#endif

#define EACT_FIO    0
#define EACT_ADDR   1
#define EACT_M_Y    2
#define EACT_TAR    3
#define EACT_SPC    4
#define EACT_TOTAL  5
#define EACT_BILLID 6

namespace Ui {
    class FormGetReceipt;
}

class FormGetReceipt : public QWidget, public DbmsContainer
{
    Q_OBJECT
    DlgSettings *mp_settings;
    SLEE_HDB_REC_LST mqh_leases;
    QVariantList mqv_lkeys;
    QVariantList mqvl_akeys;
    QString     mqstr_doc_dir;
    QStringList m_act_names;
    QString     mqstr_t_filename;
    QString     mqstr_subdir;
    QString     mqstr_root_dir;

    BillsModel *mp_bills_model;
    QDate   mqd_target;

    QList<QPair<QPair<int, int>, int> > m_act_lst;
#ifdef Q_OS_WIN

    void scan_template(SleeExcelSheet *p_sheet);
    QVariant process_act(int act, const QVariant &qv_bill_index);
    void export_reciept(SleeExcel &excel, const QVariant &qv_bill_index);

#endif
protected:
    void showEvent(QShowEvent *);
    void resizeEvent(QResizeEvent *);
    void resize_table();
public:
    explicit FormGetReceipt(DlgSettings *p_settings,  QWidget *parent = 0);

    inline void set_doc_dir_path(const QString &qstr_path) {mqstr_doc_dir = qstr_path;}
    void set_dbms(HousingDBMS *p_dbms);
    ~FormGetReceipt();

private:
    Ui::FormGetReceipt *ui;
public slots:

private slots:
    void form_reciept();
    void show_excel(bool state);
    void update_model();
    void generate_bills();
    void del_selected_bill();
    void target_date_changed();

};

#endif // FORMGETRECEIPT_H
